package day3;

public class Demo10 {

    public static void main(String[] args) {
        //定义一个数组
        int[] arr = {99, 23, 0, -1, 45, 89};

        search(arr);

        int[] arr2 = {3,4,5,6,7,8};
        printSum(arr2);

        int[] arr3 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int[] arr4 = new int[4];
        replace(arr3, arr4);

    }

    public static void printSum(int[] arr){
        for (int i = arr.length - 1; i >= 0; i--){
            System.out.print(arr[i] + "\t");
        }
        System.out.println();
    }

    public static void search(int[] arr){
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;

        for (int i = 0; i < arr.length; i++){
            max = Math.max(max, arr[i]);
            min = Math.min(min, arr[i]);
        }
        System.out.println("最大值为:" + max);
        System.out.println("最小值为:" + min);
        System.out.println();
    }

    public static void replace(int[] arr, int[] arr2){
        for (int i = 3; i < 7; i++){
            arr2[i - 3] = arr[i] *2;
            arr[i] = arr[i] * 2;
        }

        for (int i = 0; i < arr.length; i++){
            System.out.print(arr[i] + "\t");
        }
        System.out.println();
    }
}
